package com.example.moments.ssmemo.entity;

import java.util.ArrayList;
import java.util.List;

public class CommentData {
    //    这里如果增加 id 会变成什么样子
    String username;
    String content;
    String replyUsername;

    public CommentData(String username, String content, String replyUsername) {
        this.username = username;
        this.content = content;
        this.replyUsername = replyUsername;
    }

    public CommentData() {
    }

    public static CommentData parseFromDb(Comment comment) {
        return new CommentData(comment.getUsername(), comment.getContent(), comment.getReplyUsername());
//     return   new CommentData(comment.getUsername(),comment.getContent(),comment.getReplyUsername());
//        comment.getId()
    }

    public static List<CommentData> parseFromDbLst(List<Comment> comments) {
        List<CommentData> list = new ArrayList<>();
        for (Comment comment : comments) {
            list.add(parseFromDb(comment));
        }
        return list;
//        return   new  CommentData(comment.getUsername(),comment.getContent(),comment.getReplyUsername());
//     return   new CommentData(comment.getUsername(),comment.getContent(),comment.getReplyUsername());
//        comment.getId()
    }

    @Override
    public String toString() {
        return "CommentData{" +
                "username='" + username + '\'' +
                ", content='" + content + '\'' +
                ", replyUsername='" + replyUsername + '\'' +
                '}';
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getReplyUsername() {
        return replyUsername;
    }

    public void setReplyUsername(String replyUsername) {
        this.replyUsername = replyUsername;
    }
}
